package com.ibiaoke.boss.controller;

import com.ibiaoke.common.response.Res;
import com.ibiaoke.goods.entity.GoodsUnit;
import com.ibiaoke.goods.entity.XcxGoodsClass;
import com.ibiaoke.goods.service.XcxGoodsClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author Dragon
 * @date 2018/3/22/11:41;
 */
@Controller
public class BossXcxGoodsClassController {
    @Autowired
    private XcxGoodsClassService xcxGoodsClassService;
    /**
     * 商品分类
     */
    @ResponseBody
    @RequestMapping("/listXcxGoodsClass")
    public Res listXcxGoodsClass(){
        List<XcxGoodsClass> xcxGoodsClassList = xcxGoodsClassService.xcxListGoodsClass();
        return Res.create().addResponse("xcxGoodsClassList", xcxGoodsClassList);
    }

    /**
     * 添加商品分类
     * @param xcxGoodsClass
     * @return
     */
    @ResponseBody
    @RequestMapping("/saveXcxGoodsClass")
    public Res saveXcxGoodsClass(XcxGoodsClass xcxGoodsClass) {
        xcxGoodsClassService.saveXcxGoods(xcxGoodsClass);
        return new Res();
    }

    /**
     * 修改分类
     * @param xcxGoodsClass
     * @return
     */
    @ResponseBody
    @RequestMapping("/updateByXcxGoodsClassId")
    public Res updateByGoodsClassId(XcxGoodsClass xcxGoodsClass){
        xcxGoodsClassService.updateByGoodsClassId(xcxGoodsClass);
        return Res.create();
    }

    /**
     * 删除分类
     * @param xcxGoodsClassId
     * @return
     */
    @ResponseBody
    @RequestMapping("/deleteByXcxGoodsClassId")
    public Res deleteByGoodsClassId(Integer xcxGoodsClassId){
        xcxGoodsClassService.deleteByGoodsClassId(xcxGoodsClassId);
        return Res.create();
    }

    /**
     * 商品单位查询
     * @return
     */
    @ResponseBody
    @RequestMapping("/listGoodsUnit")
    public Res listGoodsUnit(){
        List<GoodsUnit> goodsUnitList = xcxGoodsClassService.listGoodsUnit();
        return Res.create().addResponse("goodsUnitList", goodsUnitList);
    }
}
